using System.Collections.Generic;

namespace Scrummer.Models
{
	public class Status
	{
		private const string InProgressString = "In Progress";
		private const string OnHoldString = "On Hold";
		private const string FutureString = "Future";
		private const string CompleteString = "Complete";
		private const string BlockedString = "Blocked";
		private const string PendingString = "Pending";
		private const string BlankString = "";

		private static IList<Status> all;
		private string name;

		public string Name
		{
			get { return name; }
			set { name = value; }
		}

		private Status(string name)
		{
			this.name = name;
		}

		public static Status InProgress = new Status(InProgressString);
		public static Status OnHold = new Status(OnHoldString);
		public static Status Future = new Status(FutureString);
		public static Status Complete = new Status(CompleteString);
		public static Status Blocked = new Status(BlockedString);
		public static Status Pending = new Status(PendingString);
		public static Status Blank = new Status(BlankString);

		public static IList<Status> All
		{
			get
			{
				if (all == null)
					InitializeList();

				return all;
			}
		}

		public static Status Decode(string name)
		{
			if (name == InProgressString)
				return InProgress;
			else if (name == OnHoldString)
				return OnHold;
			else if (name == FutureString)
				return Future;
			else if (name == CompleteString)
				return Complete;
			else if (name == BlockedString)
				return Blocked;
			else if (name == PendingString)
				return Pending;
			else
				return Blank;
		}

		private static void InitializeList()
		{
			all = new List<Status>();

			all.Add(Blank);
			all.Add(Future);
			all.Add(OnHold);
			all.Add(InProgress);
			all.Add(Blocked);
			all.Add(Pending);
			all.Add(Complete);
		}
	}
}
